package com.example.main;

import oracle.jdbc.OracleConnection;
import oracle.net.ano.AnoServices;

import java.sql.*;
import java.util.Properties;

public class Main01 {

    static String driver = "oracle.jdbc.driver.OracleDriver";
    static String url = "jdbc:oracle:thin:@101.133.174.208:1521:helowin";
    static String username = "admin";
    static String password = "1234";

    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement pstmt=null;
        ResultSet rs=null;

        try {
            Properties properties=new Properties();
//            String kerberos5 = AnoServices.AUTHENTICATION_KERBEROS5;
//            properties.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_SERVICES,username);
//            properties.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_MUTUAL,password);
            properties.setProperty("user",username);
            properties.setProperty("password",password);
            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(url,properties);
            String sql ="select * from T_USER";
            pstmt = conn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            int i=1;
            while (rs.next()){

            }
            System.out.println(rs);
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } finally {
            try {
                rs.close();
                pstmt.close();
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
}
